package org.fing.edu.uy.esbadp.core.compare.wsdl;

import java.io.Serializable;
import java.util.List;
import java.util.logging.Level;
import org.fing.edu.uy.esbadp.logger.LoggerADP;

public class ParameterDiff implements Serializable {
	
	private static final java.util.logging.Logger logger = LoggerADP.getLogger(ParameterDiff.class.getSimpleName());
    
	private static final long serialVersionUID = 1L;
	
    public static enum Modification { NEW, RENAME, DELETE };
    public static enum TypeValue { STRING, NUMERIC, NONE };
    private Modification modificationType;
    private String name;
    private String newName;
    //valor por defecto que se le pone si el parametro es nuevo
    private TypeValue typeValue;
    private String defaultValue;
    
  
	/*Si este atributo es nulo y modification es NEW, el mismo es el primer parametro de la funcion */
    private String brotherNameNode;
     
    private List<ParameterDiff> modifiedAtributesList ; 
    
    public ParameterDiff(){
        
    }

    public ParameterDiff(String name, Modification modificationType) {
        this.modificationType = modificationType;
        this.name = name;
    }
    
    public ParameterDiff(String name, String newName, Modification modificationType) {
        this.modificationType = modificationType;
        this.name = name;
        this.newName = newName;
    }

    public String getBrotherNameNode() {
        return brotherNameNode;
    }

    public void setBrotherNameNode(String brotherNameNode) {
        this.brotherNameNode = brotherNameNode;
    }

    public Modification getModificationType() {
        return modificationType;
    }

    public void setModificationType(Modification modificationType) {
        this.modificationType = modificationType;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getNewName() {
        return newName;
    }

    public void setNewName(String newName) {
        this.newName = newName;
    }

	public TypeValue getTypeValue() {
		return typeValue;
	}

	public void setTypeValue(TypeValue typeValue) {
		this.typeValue = typeValue;
	}
	             
	public String getDefaultValue() {
		return defaultValue;
	}

	public void setDefaultValue(String defaultValue) {
		this.defaultValue = defaultValue;
	}

	
	public List<ParameterDiff> getModifiedAtributesList() {
		return modifiedAtributesList;
	}

	public void setModifiedAtributesList(List<ParameterDiff> modifiedAtributesList) {
		this.modifiedAtributesList = modifiedAtributesList;
	}
	
	public void printDiff() {
        if(this.getModificationType().equals(Modification.DELETE)){
        	logger.log(Level.INFO, "    Remove Parameter {0}.", this.getName());
        }
        
        if(this.getModificationType().equals(Modification.NEW)){
        	logger.log(Level.INFO, "    New Parameter {0} - Default Value {1} -> Brother {2}.", new Object[]{this.getName(), this.getTypeValue(), this.getBrotherNameNode()});
        }
        
        if(this.getModificationType().equals(Modification.RENAME)){
        	logger.log(Level.INFO, "    Rename Parameter from {0} to {1}.", new Object[]{this.getName(), this.getNewName()});
        }
    }
    
}
